package d1208.Ljs2.Ljs23;

import java.io.FileWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class Demo1 {
    //现有一个Map<String,String>集合,包含元素（pid=10,name=张三,age=18 ）,将map集合的元素放到mapdata.properties
    public static void main(String[] args) throws Exception{
        HashMap<String, String> map = new HashMap<>();
        map.put("pid","10");
        map.put("name","张三");
        map.put("age","18");
        Properties properties = new Properties();
        for (Map.Entry<String, String> entry : map.entrySet()) {
            properties.setProperty(entry.getKey(),entry.getValue());
        }
        FileWriter fileWriter=new FileWriter("E:\\代码\\代码练习和作业\\Zuoye12月6号\\src\\Ljs2\\Ljs23\\mapdata.properties");
        properties.store(fileWriter,"");
        fileWriter.close();
    }
}
